﻿<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<link rel="STYLESHEET" type="text/css" id="SkinStyleSheet">
<title>WebNoteEditor</title>
<script language="javascript" type="text/javascript" src="../script/windialog.js"></script>
<script language="javascript">
var r;
window.onload=function()
{
	document.getElementById("InputTextFind").onkeyup=__checkbutton;
	document.getElementById("InputTextReplace").onkeyup=__checkbutton;
	document.getElementById("btnFind").onclick=__btnFind_onclick;
	document.getElementById("btnReplace").onclick=__btnReplace_onclick;
	document.getElementById("btnReplaceAll").onclick=__btnReplaceAll_onclick;
	document.getElementById("btnCancel").onclick=__btnCancel_onclick;

	AutoResizeDialogWindow();
}

function __btnOk_onclick()
{
	window.returnValue=true;
	window.close();
}

function __btnCancel_onclick()
{
	window.close();
}

function __checkbutton()
{
	if (document.getElementById("InputTextFind").value!="")
	{
		document.getElementById("btnFind").disabled=false;
		document.getElementById("btnReplace").disabled=false;
		document.getElementById("btnReplaceAll").disabled=false;
	}
	else
	{
		document.getElementById("btnFind").disabled=true;
		document.getElementById("btnReplace").disabled=true;
		document.getElementById("btnReplaceAll").disabled=true;
	}
}

function __btnFind_onclick()
{
	if (!__Find())
		alert(EditorWindow.lang_tips_findfinished);
}

function __btnReplace_onclick()
{
	if (r)
		r.text=document.getElementById("InputTextReplace").value;
	if (__Find())
	{
		return true;
	}
	else
	{
		alert(EditorWindow.lang_tips_findfinished);
		return false;
	}
}

function __btnReplaceAll_onclick()
{
	if (__Find())
	{
		r.text=document.getElementById("InputTextReplace").value;
		__btnReplaceAll_onclick();
	}
	else
	{
		alert(EditorWindow.lang_tips_replacefinished);
		return false;
	}
}


function __Find()
{
	XEditor.focus();
	var dir_X,ops_X=0,SearchResult;
	dir_X=EditorWindow._FormgetRadioValue("DirRedio",document);
	
	if (document.getElementById("checkboxWholeWord").checked)
		ops_X=2;
	if (document.getElementById("checkboxMatchCase").checked)
		ops_X=4;
	if (document.getElementById("checkboxWholeWord").checked && document.getElementById("checkboxMatchCase").checked)
		ops_X=6;
		

	r=srcObj.document.selection.createRange();
	
	if (dir_X>0)
		r.collapse(false);
	else
		r.collapse(true);
	
	SearchResult=r.findText(document.getElementById("InputTextFind").value,dir_X,ops_X);

	if (SearchResult)
	{
		try{
			r.select();
			return true;
		}
		catch(e)
		{
			return false;
		}
		
	}
	else
	{
		return false;
	}

}
</script>
</head>

<body class="dialog">
<script language="javascript" type="text/javascript">dialogTitle("lang_submenu_textfind")</script>

  <table border="0" cellpadding="3" cellspacing="0" width="390" align="center">
    <tr>
      <td colspan="2" width="296" valign="middle">
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td><script language="javascript" type="text/javascript">dialogPrintlang("lang_find")</script></td>
            <td><input type="text" id="InputTextFind" size="28" value="" class="dialogInput"></td>
          </tr>
          <tr>
            <td><script language="javascript" type="text/javascript">dialogPrintlang("lang_replace")</script></td>
            <td><input type="text" id="InputTextReplace" size="28" value="" class="dialogInput"></td>
          </tr>
        </table>
      </td>                                                                   
      <td width="85">
			<script language="javascript" type="text/javascript">document.write("<input type=\"button\" value=\""+EditorWindow.lang_findnext+"\" id=\"btnFind\"  disabled class=\"SysBTN5\">");</script>
        	<p>
        	<script language="javascript" type="text/javascript">document.write("<input type=\"button\" value=\""+EditorWindow.lang_replace+"\" id=\"btnReplace\"  disabled class=\"SysBTN5\">");</script>
      </td>
    </tr>
    <tr>
      <td width="166" height="13"> 
        <input type="checkbox" id="checkboxWholeWord" value="ON"><script language="javascript" type="text/javascript">dialogPrintlang("lang_match_wholeword")</script></td>
      <td rowspan="2" width="122">
        	<fieldset style="padding-bottom:5px"><legend><script language="javascript" type="text/javascript">dialogPrintlang("lang_search_direction")</script></legend><br>
             	<input type="radio" value="-2" name="DirRedio"><script language="javascript" type="text/javascript">dialogPrintlang("lang_up")</script>
             	<input type="radio" name="DirRedio" value="2" checked><script language="javascript" type="text/javascript">dialogPrintlang("lang_down")</script>                                                                                                                                        
			</fieldset>
      </td>
      <td width="85" height="13">
      		<script language="javascript" type="text/javascript">document.write("<input type=\"button\" value=\""+EditorWindow.lang_replaceall+"\" id=\"btnReplaceAll\"  disabled class=\"SysBTN5\">");</script> 
      </td>
    </tr>
    <tr>
      <td width="166"><input type="checkbox" id="checkboxMatchCase" value="ON"><script language="javascript" type="text/javascript">dialogPrintlang("lang_match_case");</script></td>
      <td width="85">
      		<script language="javascript" type="text/javascript">document.write("<input type=\"button\" value=\""+EditorWindow.lang_cancel+"\" id=\"btnCancel\"  class=\"SysBTN5\">");</script> 
      </td>
    </tr>
  </table>
 
</body>

</html>

